<template>
  <div class="shop">
    <!-- 搜索组件 -->
    <mysearch></mysearch>
    <div class="shopNav">
      <ul>
        <li v-for="(item, i) in shopNav" :key="i">
          <img :src="item.backgroundImage" alt="" />
          <span class="title">{{ item.title }}</span>
        </li>
        <div class="timer">
          <van-count-down :time="time">
            <template #default="timeData">
              <span class="block">{{ timeData.hours }}</span>
              <span class="colon">:</span>
              <span class="block">{{ timeData.minutes }}</span>
              <span class="colon">:</span>
              <span class="block">{{ timeData.seconds }}</span>
            </template>
          </van-count-down>
        </div>
      </ul>
    </div>
    <!-- 商品内容 -->
    <div class="content"></div>
    <div class="content"></div>
    <div class="content"></div>
    <!-- 猜你喜欢区域 -->
    <div class="guessYougLike">
      <div class="top">
        <img src="../assets/image/home/guessYougLike.webp" alt="" />
      </div>
      <div class="goods-list">
        <div class="goods-item" v-for="(item, i) in guessYougLike" :key="i">
          <goodsitem
            :goods="item"
            :saleShow="false"
            :color="'#333'"
            :bottomShow="true"
          ></goodsitem>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import mysearch from "@/components/My-search.vue";
import goodsitem from "../components/Goods_item";
export default {
  components: { mysearch, goodsitem },
  data() {
    return {
      shopNav: [], //商城分类
      time: 30 * 60 * 60 * 1000,
      guessYougLike: [], //猜你喜欢数据
      page: 1, //页数
    };
  },
  methods: {
    // 获取商城分类
    async getShopNav() {
      const { data: res } = await this.axios.get("shopNav.json");

      this.shopNav = res;
    },
    //获取猜你喜欢数据
    async getGuessYougLike() {
      const {
        data: {
          data: {
            wall: { docs: res },
          },
        },
      } = await this.axios.get(
        `https://apis.netstart.cn/mogujie/goods/personalized?page=${this.page}`
      );
      console.log(res);
      this.guessYougLike = res;
    },
  },
  created() {
    this.getShopNav();
    this.getGuessYougLike();
  },
};
</script>

<style lang="scss" scoped>
.timer {
  position: absolute;
  bottom: 30px;
  width: 100%;
  left: 0;
  right: 0;
}
.colon {
  display: inline-block;
  margin: 0 4px;
  color: #fff;
}
.block {
  display: inline-block;
  width: 22px;
  color: #fff;
  font-size: 10px;
  text-align: center;
  background-color: #333333;
}

.shopNav {
  padding-top: 60px;
  ul {
    display: flex;
    flex-wrap: wrap;
    margin-left: 10px;
    position: relative;
    li {
      width: 25%;
      margin-right: 10px;
      position: relative;
      img {
        width: 100%;
      }
      .title {
        color: #fff;
        position: absolute;
        bottom: 7px;
        left: 0;
        right: 0;
        font-weight: bold;
        font-size: 14px;
        text-align: center;
      }
    }
  }
}
.content {
  width: 100%;
  height: 115px;
}
.guessYougLike {
  background-color: #efefef;
  .top {
    width: 100%;
    img {
      width: 100%;
    }
  }
  .goods-list {
    display: flex;
    flex-wrap: wrap;
    .goods-item {
      width: 47%;
      height: 300px;
      height: auto;
      margin: 2% 0 0 2%;
    }
  }
}
</style>